import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import SingleSpaVue from "single-spa-vue";

Vue.config.productionTip = false;

const appOptions = {
  el: "#ChildVue", // 挂载到父应用中id为ChildVue的节点中
  router,
  render: (h) => h(App),
};

const childLifeCycle = SingleSpaVue({
  Vue,
  appOptions
})

// 如果是在主应用上运行
if (window.singleSpaNavigate) {
  __webpack_public_path__ = "http://localhost:10086/"
}
// 如果是独立运行
if (!window.singleSpaNavigate) {
  delete appOptions.el
  new Vue(appOptions).$mount('#app')
}

// 按照协议，子应用提供下面三个方法
export const bootstrape = childLifeCycle.bootstrap
export const mount = childLifeCycle.mount
export const unmount = childLifeCycle.unmount